package xuhaijia.lanou3g.autohome.findcar;
//                .-~~~~~~~~~-._       _.-~~~~~~~~~-.
//            __.'              ~.   .~              `.__
//          .'//                  \./                   \\`.
//        .'//            为什么坚持  想一想当初             \\`.
//      .'// .-~"""""""~~~~-._     |     _,-~~~~"""""""~-.  \\`.
//    .'//.-"                 `-.  |  .-'                 "-. \\`.
//  .'//______.============-..   \ | /   ..-============._______\\`.
//.'//____________________________\|/_____________________________\\`.
// 
//                             

import android.util.Log;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import xuhaijia.lanou3g.autohome.R;
import xuhaijia.lanou3g.autohome.base.BaseFragment;
import xuhaijia.lanou3g.autohome.base.URLValues;

/**
 * Created by 7 on 16/8/23.
 */
public class UsedCarFragment extends BaseFragment {

    private WebView webView;

    @Override
    protected int setLayout() {
        return R.layout.fragment_usedcar;
    }

    @Override
    protected void initView() {
        webView = bindView(R.id.fragment_usedcar_wv);
    }

    @Override
    protected void initData() {
        webView.loadUrl(URLValues.USEDCAR_URL);
        // webView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
        webView.setWebViewClient(new WebViewClient() {
            @Override
            public void onLoadResource(WebView view, String url) {
                if (url.startsWith("autohome")) {
                    url = url.replace("autohome://insidebrowser?url=", "");
                    url = url.replace("%3a", ":");
                    url = url.replace("%2f", "/");
                    url = url.replace("%3f", "?");
                    url = url.replace("%3d", "&");
                    webView.loadUrl(url);
                } else {
                    super.onLoadResource(view, url);
                }
            }

        });
        WebSettings webSettings = webView.getSettings();
        webSettings.setJavaScriptEnabled(true);

    }

    @Override
    public void load() {

    }

    @Override
    public void refresh() {

    }

}
